package com.github.xiaolyuh.utils;


import com.github.xiaolyuh.enums.FlushEnum;

/**
 * 缓存新增标识
 */
public class FlushHolder {

    public static final ThreadLocal<FlushEnum> HOLDER = ThreadLocal.withInitial(() -> FlushEnum.UPDATE);

    public static void set(FlushEnum flag) {
        HOLDER.set(flag);
    }

    public static FlushEnum get() {
        return HOLDER.get();
    }

    public static void clear() {
        if (HOLDER != null) {
            HOLDER.remove();
        }
    }

    /**
     * 添加操作
     * @return
     */
    public static Boolean add() {
        return FlushEnum.ADD.equals(get());
    }

}